﻿var lastSortColumn = "";
var lastSortDirection = "";
var loadingMessage = "";
var deleteConfirmationMessage = "";
var deleteConfirmationWithChildsMessage = "";
var deletingCustomerID = -1;
var LockStockInvoiceID = -1;
var deletePopupID = "DeleteConfirmation";
var divLockStockID = "LockStockConfirmation";

function initList() {

    $("th").live("click", function () {
        $(this).find("a").click();
    });

    //styled tooltip
    $('a.info-tooltip ').tooltip({
        track: true,
        delay: 0,
        fixPNG: true,
        showURL: false,
        showBody: " - ",
        top: -35,
        left: 5
    });

    $("a[id^='ListAction_Sort']").live("click", function () {
        $("#List").mask(loadingMessage + "...");
        $("#List").load($(this).attr("href"), function (response, status, xhr) {
            $("#List").unmask();
        });
        return false;
    });

    $("a[id^='ListAction_Delete']").live("click", function () {
        deletingCustomerID = $(this)[0].id.replace("ListAction_Delete_", "");
        $.colorbox({ width: "440px", inline: true, href: "#" + deletePopupID, transition: "none" });
        return false;
    });

    $("a[id^='ListAction_LockStock']").live("click", function () {
        LockStockInvoiceID = $(this)[0].id.replace("ListAction_LockStock_", "");
        $.colorbox({ width: "440px", inline: true, href: "#" + divLockStockID, transition: "none" });
        return false;
    });

    $("a[id^='ListAction_Page']").live("click", function () {
        $("#List").mask(loadingMessage + "...");
        $("#List").load($(this).attr("href"), function (response, status, xhr) {
            $("#List").unmask();
        });
        return false;
    });
}

function closePopupAndRefresh(insert) {
    $.colorbox.close();
    ShowList();
}

function closePopUp() {
    $.colorbox.close();
}

function setGridOrderClasses() {
    $("a[id^='ListAction_Sort']").each(function () {
        if ($(this).attr("id").indexOf("_" + lastSortColumn) > 0) {
            $(this).parent().addClass("table-header-repeat-selected");

        }
        else {
            $(this).parent().addClass("table-header-repeat");
        }
    });
    return false;
}

